<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace Database\Factories;

use App\Models\UserProfile;
use Illuminate\Database\Eloquent\Factories\Factory;

class UserProfileFactory extends Factory
{
    const PROVINCES = [
        '北京市', '天津市', '河北省', '山西省', '内蒙古自治区',
        '辽宁省', '吉林省', '黑龙江省', '上海市', '江苏省',
        '浙江省', '安徽省', '福建省', '江西省', '山东省',
        '河南省', '湖北省', '湖南省', '广东省', '广西壮族自治区',
        '海南省', '重庆市', '四川省', '贵州省', '云南省',
        '西藏自治区', '陕西省', '甘肃省', '青海省',
        '宁夏回族自治区', '新疆维吾尔自治区', '香港特别行政区',
        '澳门特别行政区', '台湾省',
    ];

    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = UserProfile::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'name' => $this->faker->name,
            'phone' => $this->faker->phoneNumber,
            'sex' => rand(1, 2),
            'address' => $this->faker->address,
            'birthday' => $this->faker->date(),
            'id_card_number' => rand(100000000000, 900000000000),
            'native_place' => self::PROVINCES[array_rand(self::PROVINCES)] . $this->faker->address,
            'marital_status' => rand(1, 4),
            'has_children' => 1,
            'education' => 1,
            'residence_place' => 1,
            'come_beijing_time' => $this->faker->date(),
            'now_address' => (function () {
                $num = rand(1, 900);
                $base = '北京市朝阳区金盏乡东窑村%s号';
                return sprintf($base, $num);
            })(),
            'company_name' => (function () {
                $num = rand(1, 10);
                if ($num > 5) {
                    return $this->faker->company;
                }
                return null;
            })(),
            'industry' => rand(1, 9),
            'urgent_people' => $this->faker->name,
            'urgent_people_phone' => $this->faker->phoneNumber,
            'has_contribution' => 1,
            'contribution' => $this->faker->text,
            'has_violated' => 1,
            'violated_detail' => $this->faker->text,
            'identity' => rand(1, 3),
            'area' => rand(1, 14),
            'is_company' => rand(1, 2),
            'check_status' => 1,
        ];
    }
}
